package config

import "fmt"

type DBConfig struct {
	Host 		string  		`toml:"host"`
	Port 		int		  		`toml:"port"`
	Username 	string 			`toml:"username"`
	Password	string 			`toml:"password"`
	DBName 		string 			`toml:"dbname"`
	LogShow 	bool 			`toml:"log_show"`
	LogLevel 	string 			`toml:"log_level"`
	LogDir 		string 			`toml:"log_dir"`
}

func NewDBConfig() *DBConfig {
	return &DBConfig{}
}

func (config DBConfig) FormatDBDsn() string {
	return fmt.Sprintf("%s:%s@tcp(%s:%d)/%s?charset=utf8&parseTime=True",
		config.Username, config.Password, config.Host, config.Port, config.DBName)
}